package com.inspur.ourhis_afterend.Service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.inspur.ourhis_afterend.Dao.DoctorAdviceDao;
import com.inspur.ourhis_afterend.Dao.PrescribeDao;
import com.inspur.ourhis_afterend.Service.DoctorAdviceService;
import com.inspur.ourhis_afterend.Service.PrescribeService;
import com.inspur.ourhis_afterend.mapper.DoctorAdviceMapper;
import com.inspur.ourhis_afterend.model.DoctorAdvice;
import com.inspur.ourhis_afterend.model.Prescribe;
import com.inspur.ourhis_afterend.vo.DoctorAdviceVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Wrapper;
import java.util.List;
@Service("doctorAdviceService")
public class DoctorAdviceServiceImpl implements DoctorAdviceService {
    @Resource
    DoctorAdviceMapper doctorAdviceMapper;
    @Resource
    DoctorAdviceDao doctorAdviceDao;
    @Resource
    PrescribeService prescribeService;
    @Override
    public IPage<DoctorAdviceVo> selectAdSelect(IPage iPage,Integer roid, Integer memeberid, String createtime) {
        return doctorAdviceMapper.selectAdSelect(iPage,roid, memeberid, createtime);
    }

    @Override
    public int updateByDaid(DoctorAdvice doctorAdvice) {
        return doctorAdviceMapper.updateByDaid(doctorAdvice);
    }

    @Override
    public int insert(DoctorAdvice doctorAdvice) {
        int num = doctorAdviceMapper.insertSelective(doctorAdvice);
        Prescribe prescribe = new Prescribe();
        DoctorAdvice d = doctorAdviceDao.selectByroid(doctorAdvice.getRoid());
        prescribe.setDaid(d.getDaid());
        prescribe.setMemberid(doctorAdvice.getMemeberid());
        prescribe.setStatus("0");
        prescribe.setRoid(doctorAdvice.getRoid());
        prescribeService.insertSelective(prescribe);
        return num;
    }
}
